#!/bin/sh

# Static routing configuration script
# Copyright (c) 2016-2020 Kaarle Ritvanen

if [ $MODE = start ]; then
	ACTION=add
elif [ $MODE = stop ]; then
	ACTION=del
else
	exit 1
fi

configure() {
	local class=$1
	shift

	local entry
	IFS=,
	for entry in $(eval "echo \"\$IF_$(echo $class | tr a-z A-Z)\""); do
		IFS=" "
		ip $class $ACTION $entry $*
	done
}

configure route src ${IF_ADDRESS%/*} dev $IFACE
configure rule
